/**
 * Created by chenwen on 17-5-15.
 */

class Util{
    static isArray(obj){
        return Object.prototype.toString.call(obj) === "[object Array]";
    }

    /**
     * 从第一个数组中去除第二个数组的参数
     * @param source
     * @param set
     */
    static differenceSet(source, set){
        for(var i = 0; i < source.length; i++) {
            if (set.indexOf(source[i]) !== -1) {
                source.splice(i, 1);
            }
        }
        return source;
    }

    static formatTime(date){
        return this.formatDate(date)+ " "+this.twoNumber(date.getHours())+":"+this.twoNumber(date.getMinutes())+":"+this.twoNumber(date.getSeconds());
    }
    static formatDate(date){
        return date.getFullYear()+"-"+this.twoNumber(date.getMonth()+1)+"-"+this.twoNumber(date.getDate());
    }
    static twoNumber(number){
        return number <10? "0"+number : number+"";
    }
}

module.exports = Util;